package cn.yunyichina.scheduler.jobs.common.service;

import cn.yunyichina.scheduler.jobs.common.jackson.Jackson;
import cn.yunyichina.scheduler.jobs.entity.vo.MessagePushParamsVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Map;

/**
 * Created by Lullaby on 2016/8/17.
 */
public class MessagePushRunnable implements Runnable {

    private static Logger logger = LoggerFactory.getLogger(MessagePushRunnable.class);

    @Resource
    private MessagePushService messagePushService;

    private MessagePushParamsVo params;

    public MessagePushRunnable(MessagePushParamsVo params) {
        super();
        this.params = params;
    }

    public void run() {
        logger.info("MessagePushRunnable params -> {}", Jackson.getBaseJsonData(params));

        String appId = params.getAppId();
        String templateCode = params.getTemplateCode();
        String platformType = params.getPlatformType();
        String openId = params.getOpenId();
        Map<String, Serializable> paramMap = params.getParamMap();

        messagePushService.pushMessage(appId, templateCode, platformType, openId, paramMap);
    }

}
